/**
 * http://javaelf.cn/
 * https://wwa.lanzoui.com/id130nppy9g   密码: 408509165(失效联系qq)
 * spring boot https://repo.spring.io/ui/native/libs-release-local/org/springframework/boot/spring-boot/
 *
 */
package com.ddt;




import com.ddt.daily.Daily;
import com.qiyou.javaelf.elf.GlobalSetting;
import com.qiyou.javaelf.system.Elf;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;


public class Main {
    static final Logger logger = LoggerFactory.getLogger(Main.class);
    static Map<String, User> users = new HashMap<>();

    public static void main(String[] args) throws Exception {
        GlobalSetting.copy_dlls();
        init();
        users.get("test").getMc().click(500, 500);
        users.get("test").getMc().click("战斗.bmp");
    }


    private static void unBindAll() {
        for(Map.Entry<String, User> entry : users.entrySet()){
            User u = entry.getValue();
            u.getMc().forceUnBindWindow((u.getHwnd()));

        }
    }

    public static void init() throws Exception {
        Elf.init();//全局只调用一次,提供带参的方法自定义dm版本;
        Elf elf = new Elf();

        logger.info("Ver: {}",elf.Ver());

        MatchColor mc = new MatchColor(elf);
        Map<String, Integer> usersWindow = mc.enumWindow36();

        for(Map.Entry<String, Integer> entry : usersWindow.entrySet()){
            String name = entry.getKey();
            if(Objects.equals(name, "")){
                continue;
            }
            int hwnd = entry.getValue();
            User u = new User(name, hwnd);
            u.getMc().bindWindow(hwnd);
            users.put(name, u);
        }





    }
}
